package com.robot.admin.dao;

import com.robot.admin.pojo.City;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * city数据访问接口
 *
 * @author lin
 */
public interface CityDao extends JpaRepository<City, String>, JpaSpecificationExecutor<City> {
    /**
     * 根据code查找city列表
     *
     * @param code
     * @param pageable
     * @return
     */
    @Query(value = "select * from admin.city where code like ?%", nativeQuery = true)
    public Page<City> findAllByCodeLike(String code, Pageable pageable);

    /**
     * 根据code查找city
     *
     * @param code
     * @return
     */
    public City findByCode(String code);

    /**
     * 根据name查找city
     *
     * @param name
     * @return
     */
    public City findByName(String name);
}
